package com.maxwell.googleplay.holder;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.maxwell.googleplay.R;
import com.maxwell.googleplay.bean.AppInfoBean;
import com.maxwell.googleplay.conf.Constants.URL;
import com.maxwell.googleplay.utils.BitmapHelper;
import com.maxwell.googleplay.utils.StringUtils;
import com.maxwell.googleplay.utils.UIUtils;

import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

/**
 * @author  yue
 * @创建时间 2016-3-30下午10:16:25
 * @描述     TODO
 * 
 */
public class AppItemHolder extends BaseHolder<AppInfoBean>{

	@ViewInject(R.id.item_appinfo_iv_icon)
	ImageView mIvIcon;
	@ViewInject(R.id.item_appinfo_rb_stars)
	RatingBar mRbStars;
	@ViewInject(R.id.item_appinfo_tv_des)
	TextView mTvDesc;
	@ViewInject(R.id.item_appinfo_tv_size)
	TextView mTvSize;
	@ViewInject(R.id.item_appinfo_tv_title)
	TextView mTvTtile;
	
	
	
	
	@Override
	public View initHolderView() {
		View view = View.inflate(UIUtils.getContext(), R.layout.item_app_info, null);
		//注入
		ViewUtils.inject(this, view);	
		return view;
	}

	@Override
	public void refreshHolderView(AppInfoBean data) {
		mTvDesc.setText(data.des);
		mTvSize.setText(StringUtils.formatFileSize(data.size));
		mTvTtile.setText(data.name);
		mIvIcon.setImageResource(R.drawable.ic_default);//设置默认图片
		
		
		String uri = URL.IMAGEBASEURL + data.iconUrl;
		BitmapHelper.display(mIvIcon, uri);
		
		mRbStars.setRating(data.stars);
	}



}
